//; ---------------------------------------------------------------------------
//; Object 3B - purple rock (GHZ)
//; ---------------------------------------------------------------------------
#include "purplerock.h"

#include "../../sprite.h"
#include "../../collision.h"
#include "../../objectsystemNEWER.h"

static object *obj;

//; ---------------------------------------------------------------------------
//; Sprite mappings - purple rock	(GHZ)
//; ---------------------------------------------------------------------------

byte byte_D110[11] = { 2,
		    0xF0, 0xB, 0,   0, 0xE8,
		    0xF0, 0xB, 0, 0xC,    0
};

byte *Map_PRock[1] = { byte_D110 };

//----------

void (*Rock_Index[2])() = { Rock_Main, Rock_Solid };

//PurpleRock:				; XREF: Obj_Index
void PurpleRock(object *_obj)
{
    obj = _obj;

    //moveq	#0,d0
    //move.b	obRoutine(a0),d0
    byte routine = obj->Routine/2;

    //move.w	Rock_Index(pc,d0.w),d1
    //jmp	Rock_Index(pc,d1.w)
    (*Rock_Index[routine])();
}

//; ===========================================================================
//Rock_Index:	dc.w Rock_Main-Rock_Index
//		dc.w Rock_Solid-Rock_Index
//; ===========================================================================

//Rock_Main:	; Routine 0
void Rock_Main()
{
    //addq.b	#2,obRoutine(a0)
    obj->Routine = obj->Routine + 2;
	
    //move.l	#Map_PRock,obMap(a0)
    obj->Map = Map_PRock;

    //move.w	#$63D0,obGfx(a0)
    obj->Gfx = 0x63D0;

    //move.b	#4,obRender(a0)
    obj->Render = 4;

    //move.b	#$13,obActWid(a0)
    obj->ActionWidth = 0x13;

    //move.b	#4,obPriority(a0)
    obj->Priority = 4;

    Rock_Solid();
}

//Rock_Solid:	; Routine 2
void Rock_Solid()
{
    //move.w	#$1B,d1
    word width = 27;
	
    //move.w	#$10,d2
    word jumpHeight = 16;

    //move.w	#$10,d3
    word walkHeight = 16;

    //move.w	obX(a0),d4
    word xpos = obj->X;

    //bsr.w	SolidObject
    SolidObject(obj, width, jumpHeight, walkHeight, xpos);

    //bsr.w	DisplaySprite
    DisplaySprite(obj);

    //out_of_range	DeleteObject
    if (out_of_range(obj)) { DeleteObject(obj); }

}   //rts	
